package com.mihoyo.service.impl;

import com.mihoyo.domain.Product;
import com.mihoyo.domain.Store;
import com.mihoyo.mapper.ProductMapper;
import com.mihoyo.service.ProductService;
import com.mihoyo.service.StoreService;
import com.mihoyo.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;

    @Autowired
    private StoreService storeService;

    @Override
    public AjaxResult add(Product product) {
        productMapper.add(product);
        Store store = new Store();
        store.setProductId(product.getId());
        store.setNumber(product.getNumber());
        AjaxResult ajaxResult = storeService.addStore(store);
        return ajaxResult;
    }
}
